package thread;
public class Demo9 {
    public static void main(String[] args) {
        Thread t = Thread.currentThread();


        /*Thread t = new Thread(()->{
            for (int i = 0; i < 5; i++) {
                //System.out.println(this.getName());//也可以使用this拿到线程实例但是不能在runnable内使用runnable只是一个单纯的任务,没有name属性
                System.out.println(Thread.currentThread().getName() + "存活");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println(Thread.currentThread().getName() + "销毁");//哪个线程调用Thread.currentThread()这个拿到的就是哪个线程的实例
        },"process");*/
        System.out.println(t.getName() + ":id:" + t.getId());
        System.out.println(t.getName() + ":名称:" + t.getName());
        System.out.println(t.getName() + ":状态:" + t.getState());
        System.out.println(t.getName() + ":优先级:" + t.getPriority());
        System.out.println(t.getName() + ":是不是后台线程:" + t.isDaemon());
        System.out.println(t.getName() + ":是否存活:" + t.isAlive());
        System.out.println(t.getName() + ":是否被中断:" + t.isInterrupted());
        //t.start();
        
       /*while(t.isAlive()){
            System.out.println(Thread.currentThread().getName() + ":状态:" + t.getState());
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }*/
 
 
    }
}
